package com.demo.morning;

import java.util.Objects;

/**
 * @ClassName Student
 * @Description TODO
 * @Author tianqinglong
 * @Date 9:39 2022/7/7
 * @Version 1.0
 **/
public class Student extends Object{
    private int sid;
    private String sname;
    private String sex;
    private int age;

    public int getSid() {
        return sid;
    }

    public void setSid(int sid) {
        this.sid = sid;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student(int sid, String sname, String sex, int age) {
        this.sid = sid;
        this.sname = sname;
        this.sex = sex;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Student student = (Student) o;
        return sid == student.sid && age == student.age && Objects.equals(sname, student.sname) && Objects.equals(sex, student.sex);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sid, sname, sex, age);
    }

    public static void main(String[] args) {
        Student student1 = new Student(1, "aa", "男", 25);
        Student student2 = new Student(1, "aa", "男", 25);
        System.out.println(student1.equals(student2));
        System.out.println(student1.hashCode());
        System.out.println(student2.hashCode());
    }
}
